package q009;


class Solution {
    public boolean isPalindrome(int x) {
        /*String string1 = String.valueOf(x);

        char[] chars = new char[string1.length()];

        for (int i = string1.length() - 1 , j = 0; i >= 0 ; i--,j++) {
            chars[j] = string1.charAt(i);
        }
        String string2 = new String(chars);
        return string1.equals(string2);*/

        if (x<0 || (x % 10 == 0 && x != 0))
            return false;

        int revNum = 0;
        while (x > revNum) {
            revNum = revNum * 10 + (x % 10);
            x/=10;
        }

        // 1221                     12321
        // x=12 revNum=12           x=12 revNum=123
        return x == revNum || x == (revNum / 10);
    }
}